<?PHP
  session_start();
  function __autoload($class_name){
      $namespaces = split("_",strtolower($class_name));
	  if(sizeOf($namespaces) == 3){
	    if($namespaces[0] == "plugin"){
		  require_once "../system/plugins/".$namespaces[1]."/classes/".$namespaces[2].".php";
		  $imported = true;
		}
		else if($namespaces[0] == "skin"){
		  require_once "../system/skins/".$namespaces[1]."/classes/".$namespaces[2].".php";
		  $imported = true;
		}
	  }
	  if(!$imported){
	    require_once "../system/classes/".strtolower($class_name).".php";
	  }
  }
  include("../system/settings.php");
  include("../system/filterfilename.php");
  include("../system/sys.php");
  $db = new MySQL('../system/dbsettings.php');
  $db->Connect();
  $language = new Language();
  $language->root = "../";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
  <head>
    <title>Admin-Bereich</title>
    <link href="/admin/style.css" rel="stylesheet" type="text/css" />
	<?PHP
	  CustomCSS::printStylesheet("{admin}/".$_GET['page']);
	?>
  </head>
  <body>
      <?PHP
        $user = new User();
        if($_POST['user']){
          if($user->login($_POST['user'],$_POST['password'])){
            $_SESSION['username'] = $_POST['user'];
          }
          else{
            echo "<p>Login Fehlgeschlagen!</p>";
          }
        }
	if(isset($_SESSION['username'])){
	   Menu::display(Menu::getIdByName("{admin}"),
		             "<ul id=\"adminmenue\">",
		           	 "</ul>",
					 " <li>",
					 "</li>",
					 "adminmenue");
      if(!$_GET['page']){
        $_GET['page'] = 'dashboard';
	  }
	  echo "<div id=\"content\">";
      include(filterfilename("includes/".$_GET['page']));
	  echo "</div>";
	}
	else{
          include('includes/login.php');
	}
      ?>
  </body>
</html>